use utils::ufmt;



#[cfg(any(feature = "pllm_8", feature = "pllm_25"))]
pub mod rcc;

pub mod adc;
pub mod ota;
pub mod flash;
pub mod rng;

#[derive(Debug, ufmt::derive::uDebug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UniqueId {
    pub id0: u32,
    pub id1: u32,
    pub id2: u32,
}

const UNIQUE_ADDR: u32 = 0x1FFF7A10;
const FLASH_SIZE_ADDR: u32 = 0x1FFF7A22;

pub fn unique_id() -> UniqueId {
    let id0 = unsafe {
        (UNIQUE_ADDR as *const u32).read_volatile()
    };
    let id1 = unsafe {
        ((UNIQUE_ADDR + 4) as *const u32).read_volatile()
    };
    let id2 = unsafe {
        ((UNIQUE_ADDR + 8) as *const u32).read_volatile()
    };
    UniqueId { id0, id1, id2 }
}

pub fn flash_size() -> usize {
    let size = unsafe { (FLASH_SIZE_ADDR as *const u16).read_volatile() };
    (size as usize) * 1024
}








